package com.ixuestar.util;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;

public class ReturnResult {
	
	/**
	 * 正确的返回结果
	 * @param jsonObject
	 * @return
	 */
	public static Map<String, Object> correctResult(JSONObject jsonObject){
		//加密
//		String encrypt_ixuestar = DESUtil.encrypt_ixuestar(jsonObject.toJSONString());
		//添加
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("code", 0);
		hashMap.put("success", true);
		hashMap.put("message", "执行成功");
		hashMap.put("data", jsonObject);
		return hashMap;
	}
	
	/**
	 * 异常的返回结果
	 * @param jsonObject
	 * @return
	 */
	public static Map<String, Object> wrongResult(){
		//添加
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("code", -1);
		hashMap.put("success", false);
		hashMap.put("message", "执行失败");
		hashMap.put("data", new HashMap<>());
		return hashMap;
	}
	
	/**
	 * 返回其他结果
	 * @param jsonObject
	 * @return
	 */
	public static Map<String, Object> otherResult(int code,String message){
		//添加
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("code", code);
		hashMap.put("success", true);
		hashMap.put("message", message);
		hashMap.put("data", new HashMap<>());
		return hashMap;
	}
	
	/**
	 * 返回其他结果
	 * @param jsonObject
	 * @return
	 */
	public static Map<String, Object> otherJSONObjectResult(int code,JSONObject jsonObject,String message){
		//添加
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("code", code);
		hashMap.put("success", true);
		hashMap.put("message", message);
		hashMap.put("data", jsonObject);
		return hashMap;
	}
}
